window._MWX = {
	
	showCustomAd:function(){
		
		console.log("模板广告");
		
		if(cc.sys.platform === cc.sys.WECHAT_GAME){
			
			
			let customad = wx.createCustomAd({
				  adUnitId: 'adunit-fa6a61fb410790fd',
				  adIntervals:30,
				  style: {
					  left: 0,
					  top: 0,
					  fixed: true
				  }
				});
			
			customad.onError(err => {
				  console.log(err)
				})
			
			customad.show();
			
			
		}
		
	},
	
	showLbVideo:function(){
		/*
		if(cc.sys.platform === cc.sys.WECHAT_GAME){
		
			if(!window.videoLbAd){
		
				window.videoLbAd = wx.createRewardedVideoAd({adUnitId:'adunit-7535a0cec7bfe303'});
				
				window.videoLbAd.onError(err => {
					_TIPS.showMessage('激励视频 广告显示异常');
				})
				
				window.videoLbAd.onClose(res => {
					console.log('积分激励广告完成');
					if (res && res.isEnded || res === undefined) {
						if(_CHESSJFUI._MAINLABEL){
						_TIPS.showMessage('播放完成获得积分：1000');
						_LOCALJF.addJIFEN(1000);
						_HTTP.getJf();
						}
					}
				})
				
			}
			
			window.videoLbAd.show().catch(() => {
				videoLbAd.load().then(() => videoLbAd.show()).catch(err => {
					_TIPS.showMessage('激励视频 广告显示失败')
				})
			});
				
		}else{
			_TIPS.showMessage('播放完成获得积分：1000');
			_LOCALJF.addJIFEN(1000);
			_HTTP.getJf();
			
		}*/
		_MWX.showRandomVideo();
	},

	showRandomVideo:function(){
		
		if(cc.sys.platform === cc.sys.WECHAT_GAME){
		
			if(!window.videoRdAd){
		
				window.videoRdAd = wx.createRewardedVideoAd({adUnitId:'adunit-fcb0265d4b5efe21'});
				
				window.videoRdAd.onError(err => {
					_TIPS.showMessage('激励视频 广告显示异常');
				})
				
				window.videoRdAd.onClose(res => {
					console.log('随机次数激励广告完成');
					if (res && res.isEnded || res === undefined) {
						_MWX.getReward();
					}
	
				})
				
			}
			
			window.videoRdAd.show().catch(() => {
				videoRdAd.load().then(() => videoRdAd.show()).catch(err => {
					_TIPS.showMessage('激励视频 广告显示失败')
				})
			});
				
		}else{
			_MWX.getReward();
		}
		
	},

	getReward:function(){

		if(window._RANDOM){
			_TIPS.showMessage('播放完成，获得随机次数：50');
			_LOCALJF.addRandom(50);
			window._RANDOM.refreshButtons();
		}else if(_CHESSJFUI._MAINLABEL){
			_TIPS.showMessage('播放完成获得积分：1000');
			_LOCALJF.addJIFEN(1000);
			_HTTP.getJf();
		}else {
			_TIPS.showMessage('激励异常');
		}

	}
}